package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.common.BaseContext;
import com.itheima.entity.AddressBook;
import com.itheima.entity.ShoppingCart;
import com.itheima.mapper.AddressBookMapper;
import com.itheima.mapper.ShoppingCartMapper;
import com.itheima.service.AddressBookService;
import com.itheima.service.ShoppingCartService;
import org.springframework.stereotype.Service;

@Service
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements ShoppingCartService {
//清除购物车
    @Override
    public void clean(Long id) {
        //        sql:delete from shopping_cart where user_id = ?
        LambdaQueryWrapper<ShoppingCart> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(id!=null,ShoppingCart::getUserId,id);
        this.remove(queryWrapper);
    }
}
